﻿using System;
using System.Web.UI.WebControls;
using BLL;

public partial class StatisticData_OnceandPassRate_OandPRbyCIDShift : System.Web.UI.Page
{
    private Test_PRT test;
    private DateTime starttime
    {
        get { return DateTime.Parse(ViewState["starttime"].ToString()); }
        set { ViewState["starttime"] = value; }
    }
    private DateTime stoptime
    {
        get { return DateTime.Parse(ViewState["stoptime"].ToString()); }
        set { ViewState["stoptime"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDTBetween();
        }
    }

    protected void BindDTBetween()
    {
        this.DropDownList1.DataSource = DayandNightShift.list;
        this.DropDownList1.DataTextField = "steptext";
        this.DropDownList1.DataValueField = "stepvalue";
        this.DropDownList1.DataBind();
    }

    public StatisticData_OnceandPassRate_OandPRbyCIDShift()
    {
        test = new Test_PRT();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string day = this.TextBox1.Text.Trim();
        string[] dtbetween = this.DropDownList1.SelectedValue.Split(',');
        starttime = DateTime.Parse(day + dtbetween[0]);
        stoptime = DateTime.Parse(day + dtbetween[1]);
        if (starttime > stoptime)
        {
            stoptime = stoptime.AddDays(1);
        }
        BindOPR();
        BindPR();
    }

    private void BindOPR()
    {
        GridView1.DataSource = test.GetOPRbyCID_DT(starttime, stoptime);
        GridView1.DataBind();
        GridView1.Visible = true;
    }

    private void BindPR()
    {
        GridView2.DataSource = test.GetPRbyCID_DT(starttime, stoptime);
        GridView2.DataBind();
        GridView2.Visible = true;
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindOPR();
    }

    protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView2.PageIndex = e.NewPageIndex;
        BindPR();
    }
}
